<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<base href="${BaseContext }">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
	<!-- 引入JQuery  bootstrap.js-->
	<script src="static/js/jquery-3.2.1.min.js"></script>
	<script src="static/js/bootstrap.min.js"></script>
<style type="text/css">
th, td {
	text-align: center;
}
</style>
</head>
<body>
	<!-- 顶栏  -->
	<jsp:include page="include/top.jsp"></jsp:include>
	<!-- 菜单 -->
	<%-- <jsp:include page="menu.jsp"></jsp:include> --%>	
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<!-- 菜单 -->	
			<jsp:include page="include/menu.jsp"></jsp:include>
			<div class="col-md-10">
				<div class="panel panel-default">
				    <div class="panel-heading">
						<div class="row">
					    	<h3 class="col-md-5">专家管理</h3>
							<form class="bs-example bs-example-form col-md-5" role="form" style="margin: 20px 0 10px 0;" action="admin/manageProfessor.do" id="form1" method="post">
								<div class="input-group">
									<input type="text" class="form-control" placeholder="请输入姓名" value="${pName}" name="pName">
									<span class="input-group-addon btn" id="sub">搜索</span>
								</div>
							</form>
							<!-- 翻页form -->
							<form id="hiddenForm" action="admin/manageProfessor.do" method="post">
								<input type="hidden" name="pName" value="${pName}">
								<input type="hidden" name="pageNum" id="pageNum">
							</form>
							<button class="btn btn-default col-md-1" style="margin-top: 20px" onClick="addOne();">
								添加
								<sapn class="glyphicon glyphicon-plus"/>
							</button>

						</div>
				    </div>
				    <table class="table table-bordered">
					        <thead>
					            <tr>
									<th>专家编号</th>
									<th>姓名</th>
									<th>性别</th>
									<th>出生年份</th>
									<th>学历</th>
									<th>职称</th>
									<th>操作</th>
					            </tr>
					        </thead>
					        <tbody>
							<c:forEach  items="${pageInfo.list}" var="professor">
								<tr>
									<td>${professor.pId}</td>
									<td>${professor.pName}</td>
									<td>
										<c:if test="${professor.pSex==0 }">男</c:if>
										<c:if test="${professor.pSex==1 }">女</c:if>
									</td>
									<td><fmt:formatDate value="${professor.pBirth}" dateStyle="medium" /></td>
									<td>
										<c:if test="${professor.pDgree==0 }">硕士</c:if>
										<c:if test="${professor.pDgree==1 }">博士</c:if>
										<c:if test="${professor.pDgree==2 }">博士后</c:if>
									</td>
									<td>
										<c:if test="${professor.pTitle==0 }">副教授</c:if>
										<c:if test="${professor.pTitle==1 }">教授</c:if>
										<c:if test="${professor.pTitle==2 }">副院长</c:if>
										<c:if test="${professor.pTitle==3 }">院长</c:if>
									</td>
									<td>
										<button class="btn btn-default btn-xs btn-info" onClick="location.href='admin/edit.do?id=${professor.pId}'">修改</button>
										<button class="btn btn-default btn-xs btn-danger btn-primary" onClick="confirmd(this,${professor.pId});">删除</button>
										<!--弹出框-->
									</td>
								</tr>
							</c:forEach>
					        </tbody>
				    </table>
				</div>
				<!-- 页码 -->
				<jsp:include page="include/pageInfo.jsp"></jsp:include>
			</div>
		</div>
	</div>
	<!-- footer -->
	<jsp:include page="include/footer.jsp"></jsp:include>
</body>
	<script type="text/javascript">
		$("#nav li:nth-child(2)").addClass("active")
		/* 删除按钮 */
        function confirmd(obj,professorId) {
            var msg = "您真的确定要删除吗？"+professorId+"！";
            if (confirm(msg)){
				$.post('admin/delete.do',{'id':professorId},function(data){
					if(data.success){
						//删除成功，不刷新整个页面，显示还未删除的数据，提示结果
						//window.location.reload();
						$(obj).parent().parent().remove();
					}
				},'json')
            }
        }
		/* 搜索按钮 */
		$(function(){
        	$("#sub").click(function () {
    	        $("#form1").submit();
	        });
		})
		/* 添加按钮 */
		function addOne(){
			window.location.href = 'admin/add.do';
		}
        /* 翻页按钮 */
        function goPage(page){
			$("#pageNum").val(page);
			$("#hiddenForm").submit();
		}
        
	</script>
</html>